﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KendoMvcUI.Core;
using KendoMvcUI.Common;
using System.Web.Mvc;

namespace KendoMvcUI.UI
{
    public class Splitter:KendoUIBase
    {
        public Splitter(KendoUIControlSettings settings,ViewContext context,IViewDataContainer container)
            :base(settings,context,container)
        { }
    }
    public class SplitterSettings : KendoUIControlSettings
    {
        public SplitterSettings()
            : base("kendoSplitter")
        {
            //Panes = new List<PaneSettings>();
        }
        /// <summary>
        /// Supported values are "horizontal" and "vertical".
        /// </summary>
        public string Orientation { get; set; }
        [PropertySetting(IsIngoreForJavaScript=true)]
        public Action<List<PaneSettings>> Panes { get; set; }
        #region 事件
        public string On_Collapse { get; set; }
        public string On_ContentLoad { get; set; }
        public string On_Error { get; set; }
        public string On_Expand { get; set; }
        public string On_LayoutChange { get; set; }
        public string On_Resize { get; set; }
        #endregion
        public override string ToJsSettings()
        {
            string jsScript = base.ToJsSettings();
            if (!jsScript.EndsWith(","))
                jsScript += ",";
            string panesStr = "";
            if(Panes!=null)
            {
                List<PaneSettings> panes=new List<PaneSettings>();
                Panes(panes);
                foreach (var pane in panes)
                {
                    string paneStr = "{" + pane.ToString() + "}，";
                }
                jsScript += string.Format("[{0}]", panesStr.TrimEnd(','));
            }
            
            
            return jsScript.TrimEnd(',');
        }
    }
    public class PaneSettings : KendoUIControlSettings
    {
        public PaneSettings()
            : base("kendoPane")
        { }
        public bool? Collapsed { get; set; }
        public string CollapsedSize { get; set; }
        public bool? Collapsible { get; set; }
        public string ContentUrl { get; set; }
        public int? Max { get; set; }
        public int? Min { get; set; }
        public bool? Resizable { get; set; }
        public bool? Scrollable { get; set; }
        public string Size { get; set; }
    }
}
